package com.lanlian.commonlib.common;

import com.lanlian.commonlib.BaseApplication;
import com.lanlian.commonlib.R;
import com.lanlian.utillib.PreferencesUtils;

public class SystemConfig {

    public static final int IMG_DEFAULT_BACKGROUND = R.drawable.background_d7d7d7;
    public static final int IMG_DEFAULT_ABLUM = R.mipmap.dataupload_img_bg;

    //MQ开曼测试环境配置
    private static String MQ_CAYMAN_IP_QA = "mq.eoetop.com";
    private static int MQ_CAYMAN_PORT_QA = 5672;
    private static String MQ_CAYMAN_USER_QA = "cc";
    private static String MQ_CAYMAN_PASSWORD_QA = "cc123";
    //MQ香港测试环境配置
    private static String MQ_HK_IP_QA = "mq.eoetop.com";
    private static int MQ_HK_PORT_QA = 5672;
    private static String MQ_HK_USER_QA = "cc";
    private static String MQ_HK_PASSWORD_QA = "cc123";
    //MQ开曼线上环境配置
    private final static String MQ_CAYMAN_IP_ONLINE = "kyc-mq.eoepro.com";
    private final static int MQ_CAYMAN_PORT_ONLINE = 55520;
    private final static String MQ_CAYMAN_USER_ONLINE = "cc";
    private final static String MQ_CAYMAN_PASSWORD_ONLINE = "LE9fWcN5Tx6fcSRE";
    //MQ香港线上环境配置
    private final static String MQ_HK_IP_ONLINE = "mq.lionky.com";
    private final static int MQ_HK_PORT_ONLINE = 14113;
    private final static String MQ_HK_USER_ONLINE = "cc";
    private final static String MQ_HK_PASSWORD_ONLINE = "cc@ELl131";

    //socket开曼测试环境配置
    private final static String SOCKET_CAYMAN_IP_QA = "kmanage.chinaeast2.cloudapp.chinacloudapi.cn";
    private final static int SOCKET_CAYMAN_PORT_QA = 40080;
    //socket香港测试环境配置
    private final static String SOCKET_HK_IP_QA = "trade.eoetop.com";
    private final static int SOCKET_HK_PORT_QA = 40080;
    //socket开曼线上环境配置
    private final static String SOCKET_CAYMAN_IP_ONLINE = "kyc-trade.eoepro.com";
    private final static int SOCKET_CAYMAN_PORT_ONLINE = 55530;
    //socket香港线上环境配置
    private final static String SOCKET_HK_IP_ONLINE = "trade.lionky.com";
    private final static int SOCKET_HK_PORT_ONLINE = 14114;

    public static final int REQUEST_TAKE_PHOTO = 1007;
    public static final int REQUEST_GALLERY = 1008;
    public static final int REQUEST_CLIP = 1009;
    public static final int REQUEST_PERMISSIONS = 10010;

    public static final String HTTP_NETWORK_ERROR = "-1";       //HTTP请求网络错误
    public static final String HTTP_NETWORK_SUCCESS = "0";      //HTTP请求成功
    public static final String HTTP_TOKEN_EXPIRE = "000002";    //用户登录过期，请重新登录

    public static final String IMAGE_BASE_URL = "http://package.foxtry.com/";

    private static int HOME_ENVIRONMENT = -1;
    public final static int CAYMAN_ONLINE = 0;                  //开曼线上环境
    public final static int HONGKONG_ONLINE = 1;                //香港线上环境
    public final static int CAYMAN_QA = 2;                      //开曼测试环境
    public final static int HONGKONG_QA = 3;                    //香港测试环境

    private final static String HOME_URL_CAYMAN_QA = "http://kmanage.chinaeast2.cloudapp.chinacloudapi.cn/";        //开曼测试环境
    private final static String HOME_URL_HK_QA = "http://tmanage.chinaeast2.cloudapp.chinacloudapi.cn:8080/";       //香港测试环境
    private final static String HOME_URL_CAYMAN_ONLINE = "http://kyc-manage.chinaeast2.cloudapp.chinacloudapi.cn:55501/";//开曼正式环境
    private final static String HOME_URL_HK_ONLINE = "http://manage.chinaeast2.cloudapp.chinacloudapi.cn:14115/";   //香港正式环境

    public static String getUserUrl() {
        switch (getHomeEnvironment()) {
            case CAYMAN_ONLINE:
                return HOME_URL_CAYMAN_ONLINE;
            case HONGKONG_ONLINE:
                return HOME_URL_HK_ONLINE;
            case CAYMAN_QA:
                return HOME_URL_CAYMAN_QA;
            case HONGKONG_QA:
                return HOME_URL_HK_QA;
            default:
                return HOME_URL_CAYMAN_ONLINE;
        }
    }

    public static String getSocketIp() {
        switch (getHomeEnvironment()) {
            case CAYMAN_ONLINE:
                return SOCKET_CAYMAN_IP_ONLINE;
            case HONGKONG_ONLINE:
                return SOCKET_HK_IP_ONLINE;
            case CAYMAN_QA:
                return SOCKET_CAYMAN_IP_QA;
            case HONGKONG_QA:
                return SOCKET_HK_IP_QA;
            default:
                return SOCKET_CAYMAN_IP_ONLINE;
        }
    }

    public static int getSocketPort() {
        switch (getHomeEnvironment()) {
            case CAYMAN_ONLINE:
                return SOCKET_CAYMAN_PORT_ONLINE;
            case HONGKONG_ONLINE:
                return SOCKET_HK_PORT_ONLINE;
            case CAYMAN_QA:
                return SOCKET_CAYMAN_PORT_QA;
            case HONGKONG_QA:
                return SOCKET_HK_PORT_QA;
            default:
                return SOCKET_CAYMAN_PORT_ONLINE;
        }
    }

    public static RabbitMqConfig getMQConfig() {
        switch (getHomeEnvironment()) {
            case CAYMAN_ONLINE:
                return new RabbitMqConfig(MQ_CAYMAN_IP_ONLINE, MQ_CAYMAN_USER_ONLINE,
                        MQ_CAYMAN_PASSWORD_ONLINE, MQ_CAYMAN_PORT_ONLINE);
            case HONGKONG_ONLINE:
                return new RabbitMqConfig(MQ_HK_IP_ONLINE, MQ_HK_USER_ONLINE,
                        MQ_HK_PASSWORD_ONLINE, MQ_HK_PORT_ONLINE);
            case CAYMAN_QA:
                return new RabbitMqConfig(MQ_CAYMAN_IP_QA, MQ_CAYMAN_USER_QA,
                        MQ_CAYMAN_PASSWORD_QA, MQ_CAYMAN_PORT_QA);
            case HONGKONG_QA:
                return new RabbitMqConfig(MQ_HK_IP_QA, MQ_HK_USER_QA,
                        MQ_HK_PASSWORD_QA, MQ_HK_PORT_QA);
            default:
                return new RabbitMqConfig(MQ_CAYMAN_IP_ONLINE, MQ_CAYMAN_USER_ONLINE,
                        MQ_CAYMAN_PASSWORD_ONLINE, MQ_CAYMAN_PORT_ONLINE);
        }
    }

    public static int getHomeEnvironment() {
        if (HOME_ENVIRONMENT != -1) {
            return HOME_ENVIRONMENT;
        } else {
            return PreferencesUtils.getInt(BaseApplication.getInstance(), "HOME_ENVIRONMENT", CAYMAN_QA);
        }
    }

    public static void setHomeEnvironment(int homeEnvironment) {
        PreferencesUtils.putInt(BaseApplication.getInstance(), "HOME_ENVIRONMENT", homeEnvironment);
        HOME_ENVIRONMENT = homeEnvironment;
    }

}
